
package interface_grafica;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import listeners.ListenersTelaCarteiraSocios;
import listeners.ListenersTelaConsultaDoacao;
import listeners.ListenersTelaConsultaProjetos;
import listeners.ListenersTelaConsultaSocio;

public class TelaConsultaProjetos extends javax.swing.JPanel {
    
    private static TelaConsultaProjetos instance;

    public static TelaConsultaProjetos getInstance() {
        if (instance == null) {
            instance = new TelaConsultaProjetos();
        }
        return instance;
    }     
    
    public TelaConsultaProjetos() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaProjetos = new javax.swing.JTable();
        tipoBuscaProjeto = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        campoBuscaProjeto = new javax.swing.JTextField();
        botaoBuscaProjeto = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1063, 557));

        tabelaProjetos.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tabelaProjetos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "ID", "Nome", "Data de inicio", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaProjetos.getTableHeader().setReorderingAllowed(false);
        tabelaProjetos.getSelectionModel().addListSelectionListener(new ListenersTelaConsultaProjetos());
        
        jScrollPane1.setViewportView(tabelaProjetos);
        tabelaProjetos.getColumnModel().getColumn(1).setResizable(false);

        tipoBuscaProjeto.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tipoBuscaProjeto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID", "Data de inicio" }));

        jLabel6.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel6.setText("Filtrar por");

        campoBuscaProjeto.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N

        botaoBuscaProjeto.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        botaoBuscaProjeto.setText("Pesquisar");
        botaoBuscaProjeto.addActionListener(new ListenersTelaConsultaProjetos());

        btCancelar.setText("Cancelar");
        btCancelar.addActionListener(new ListenersTelaConsultaProjetos());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Consulta de Projetos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btCancelar)
                .addGap(62, 62, 62))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(82, 82, 82)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tipoBuscaProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoBuscaProjeto)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(botaoBuscaProjeto))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 844, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(456, 456, 456)
                        .addComponent(jLabel1)))
                .addContainerGap(137, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 105, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tipoBuscaProjeto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel6)
                        .addComponent(botaoBuscaProjeto))
                    .addComponent(campoBuscaProjeto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14)
                .addComponent(btCancelar)
                .addGap(46, 46, 46))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoBuscaProjeto;
    private javax.swing.JButton btCancelar;
    private javax.swing.JTextField campoBuscaProjeto;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabelaProjetos;
    private javax.swing.JComboBox tipoBuscaProjeto;
    // End of variables declaration//GEN-END:variables

    public JButton getBotaoBuscaProjeto() {
        return botaoBuscaProjeto;
    }

    public JButton getBtCancelar() {
        return btCancelar;
    }

    public String getCampoBuscaProjeto() {
        return campoBuscaProjeto.getText();
    }

    public JTable getTabelaProjetos() {
        return tabelaProjetos;
    }

    public JComboBox getTipoBuscaProjeto() {
        return tipoBuscaProjeto;
    }

    public DefaultTableModel getDtm() {

  		DefaultTableModel dtm = (DefaultTableModel) tabelaProjetos.getModel();

  		return dtm;
  	}
      
     public void limpaDtm(){		
  		getDtm().setNumRows(0);
  	}

    
}
